package com.wo.cloud.core.constant;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/4/27 16:39
 * Description:
 */
public class ClientDetailsConstant {
    private static final String CLIENT_FIELDS_FOR_UPDATE = "resource_ids, scope, "
            + "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity_seconds, "
            + "refresh_token_validity_seconds, additional_information, autoapprove, "
            + "id, update_by, update_time, create_by, create_time, deleted_flag";

    private static final String CLIENT_FIELDS = "client_secret, " + CLIENT_FIELDS_FOR_UPDATE;

    private static final String BASE_FIND_STATEMENT = "select client_id, " + CLIENT_FIELDS
            + " from sys_client_details";

    private static final String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id";

    private static final String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ?";

    private static final String DEFAULT_INSERT_STATEMENT = "insert into oauth_client_details (" + CLIENT_FIELDS
            + ", client_id) values (?,?,?,?,?,?,?,?,?,?,?)";

    private static final String DEFAULT_UPDATE_STATEMENT = "update oauth_client_details " + "set "
            + CLIENT_FIELDS_FOR_UPDATE.replaceAll(", ", "=?, ") + "=? where client_id = ?";

    private static final String DEFAULT_UPDATE_SECRET_STATEMENT = "update oauth_client_details "
            + "set client_secret = ? where client_id = ?";

    private static final String DEFAULT_DELETE_STATEMENT = "delete from oauth_client_details where client_id = ?";

    public static final String deleteClientDetailsSql = DEFAULT_DELETE_STATEMENT;

    public static final String findClientDetailsSql = DEFAULT_FIND_STATEMENT;

    public static final String updateClientDetailsSql = DEFAULT_UPDATE_STATEMENT;

    public static final String updateClientSecretSql = DEFAULT_UPDATE_SECRET_STATEMENT;

    public static final String insertClientDetailsSql = DEFAULT_INSERT_STATEMENT;

    public static final String selectClientDetailsSql = DEFAULT_SELECT_STATEMENT;
}
